# -*- coding:utf-8 -*-

"""
新手产品推荐

"""
from aw import *
from autotest import *


class Test_003(TestCase):
    def setUp(self):
        print("Test_001 setUp")
        Common.selectProduct("ZC201811012059031565554--会员稳盈45天")
        Common.selectTemplate()
        Common.getProducts()
        Common.getProducts(product_type=2)
        Common.getProducts(product_type=15)

        Common.selectProductRate("ZC201811012104535469293")

        # 创建计划类产品--新手
        Common.createProduct(product_Type="月增", tmpId=178, raise_end_time="2018-11-29 23:59:59", productType=2)
        Common.createProduct(product_Type="新人周增", tmpId=176, raise_end_time="2018-11-29 23:59:59", productType=2)
        Common.createProduct(product_Type="新人双月增", tmpId=177, raise_end_time="2018-11-29 23:59:59", productType=2)
        Common.createProduct(product_Type="新人季增", tmpId=175, raise_end_time="2018-11-29 23:59:59", productType=2)

        # 创建定期产品 -- 新手
        Common.createProduct(prodType="dq", tmpId=475, product_term=30, raise_end_time="2018-11-29 23:59:59",
                             productType=2)
        Common.createProduct(prodType="dq", tmpId=475, product_term=45, raise_end_time="2018-11-29 23:59:59",
                             productType=2)
        Common.createProduct(prodType="dq", tmpId=476, product_term=180, raise_end_time="2018-11-29 23:59:59",
                             productType=2)
        Common.createProduct(prodType="dq", tmpId=476, product_term=180, raise_end_time="2018-11-29 23:59:59",
                             productType=2)
        Common.createProduct(prodType="dq", tmpId=477, product_term=365, raise_end_time="2018-11-29 23:59:59",
                             productType=2)

        Common.dumpProduct("ZC201810231934317207970")
        Common.loadProduct("ZC201810231704586551135")

        Common.cleanCache("ZC201811012104395127197")
        Common.cleanCache("1100111023")
        Common.cleanCache("1100099819")
        Common.getProducts()
        Common.getProducts(product_type=2)
        Common.getProducts(product_type=15)

        Common.updateProduct("PD201811012110157764034--新人月增1811012-2", product_name="稳赢180天-1811012-2")
        Common.updateProduct("PD201810271630456770938--稳盈30天", product_name="稳赢180天2-1810271", product_term=180)
        Common.updateProduct("PD201811012110157764034--会员稳盈45天", product_term=180,raise_end_time="2018-11-22 19:44:59")
        Common.dumpProduct("PD201811012110157764034")

    def test(self):
        Common.getRecordProduct(product_type=2)
        Common.getRecordProduct(product_type=15)

        zou_zeng = ["ZC201811012104395127197--新人周增1811012"]
        # for pno in zou_zeng:
        #     Common.updateProduct(pno, raise_start_time="2018-11-04 20:45:58")
        #     Common.updateProduct(pno, product_status=6, raise_end_time="2018-10-22 19:44:59", )

        # 依次会员月增1 会员月增2
        yue_zeng = ["ZC201811012059031565554--新人月增1811012", "ZC201811012059549126067--新人月增1811012-2", ]

        # for pno in yue_zeng:
        #     Common.updateProduct(pno, product_status=6, raise_end_time="2018-10-22 19:44:59", )
        #     Common.updateProduct(pno, raise_start_time="2018-11-06 20:45:58")
        #     Common.raiseInterest("ZC201811012059549126067--新人月增1811012", interest=0.01)
        #     Common.raiseInterest("ZC201811012059031565554--新人月增1811012",interest=0.03)

        shuang_yue_zeng = ["ZC201811021816293755389--新人双月增1811012"]

        # for pno in shuang_yue_zeng:
        #     Common.updateProduct(pno, product_status=5, raise_end_time="2018-10-22 19:44:59", )
        #     Common.updateProduct(pno, raise_start_time="2018-11-06 20:45:58")
        #     Common.updateProduct(pno, raise_end_time="2018-11-22 20:45:58")
        #     Common.dumpProduct(pno)


        ji_zeng = ["ZC201811012105066570507--新人季增1811012"]
        # for pno in ji_zeng:
        #     Common.updateProduct(pno, product_status=6, raise_end_time="2018-10-22 19:44:59", )
        #     Common.updateProduct(pno, raise_start_time="2018-11-06 20:45:58")


        # 稳赢 依次是30天 45天 180天 365天
        wen_yin = ["PD201811012109322265974--稳盈30天",
                   "PD201811012109462285988--稳盈45天",
                   "PD201811012110009548998--稳盈180天1"
                   "PD201811012110157764034--稳盈180天2",
                   "PD201811012110297201061---稳盈365天"]

        for pno in zou_zeng + yue_zeng + shuang_yue_zeng + ji_zeng + wen_yin:
            Common.updateProduct(pno, product_status=6, raise_end_time="2018-10-22 19:44:59", )
            Common.updateProduct("ZC201811012104395127197", product_status=5, raise_end_time="2018-11-22 19:44:59", )
            Common.loadProduct("ZC201811012059031565554")
            Common.updateProduct(pno,raise_end_time="2018-11-22 19:44:59", )

        Common.raiseInterest("PD201811012110009548998",interest=0.03)
            #
            # Common.dumpProduct(pno)
            # #       Common.loadProduct(pno)
            # Common.updateProduct(pno, product_status=5, raise_start_time="2018-10-26 20:45:58",
            #                      raise_end_time="2018-11-22 19:44:59", )


        # 新人标下架 包含周增
        for pno in ['ZC201809271633381496398', 'ZC201809271634118418470', 'ZC201809271637526907900']+['PD201811021049320186896']:
            # Common.dumpProduct(pno)
            Common.updateProduct("ZC201811021925113561234", product_status=6, raise_end_time="2018-10-22 19:44:59", )

    def tearDown(self):
        print("Test_001 tearDown")
